import 'package:dss_base/dss_base.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DemoPage extends BaseStatelessWidget {
  final String name;
  final int age;
  final String? friend;

  const DemoPage({
    super.key,
    required this.name,
    required this.age,
    this.friend,
  });

  @override
  Widget onBuild(BuildContext context) {
    Widget content = ListView(
      children: [
        Text('name: $name'),
        Text('age: $age'),
        Text('friend: $friend'),
      ],
    );
    content = Scaffold(
      appBar: AppBarX(
        title: 'Demo Page',
        onBackPressed: () => NavigatorUtil.back(result: name),
      ),
      body: content,
    );
    return PopScope(
      canPop: false,
      onPopInvokedWithResult: (didPop, result) {
        if (didPop) return;
        NavigatorUtil.back(result: name);
      },
      child: content,
    );
  }
}
